import frida
import os


def adb_forward():
    os.system("adb forward tcp:27042 tcp:27042")
    os.system("adb forward tcp:27043 tcp:27043")


get_res = """
rpc.exports = {
    getphone: function(phone){
        var res
        Java.perform(function(){
            var StringUtils = Java.use('com.wuba.commons.utils.StringUtils')
            res = StringUtils.getStr(phone).substring(0, 11)
            }
        )
    return res
    }
};
"""

def decrypt_phone(script, phone):
    return script.exports.getPhone(phone)

def get_script():
    adb_forward()
    process = frida.get_remote_device().attach('com.wuba')
    script = process.create_script(get_res)
    script.load()
    return script


if __name__ == '__main__':
    scripts = get_script()
    print(decrypt_phone(scripts, "36E26FDD8EA39C57AF58F94DE93C00A8"))